package com.tiger.log.api;

import com.tiger.log.common.response.Response;
import com.tiger.log.server.service.SysRecordLogService;
import org.springframework.context.annotation.Description;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName RecordController
 * @Description TODO
 * @Author huxuehao
 **/

@RestController
@RequestMapping("/log/record")
public class RecordController {
    private final SysRecordLogService sysRecordLogService;

    public RecordController(SysRecordLogService sysRecordLogService) {
        this.sysRecordLogService = sysRecordLogService;
    }

    @GetMapping("/get-all")
    @Description("获取所有的记录")
    public Response getAll() {
        return Response.success(sysRecordLogService.getAll());
    }

    @GetMapping("/get-by-id")
    @Description("根据id获取记录")
    public Response getById(@RequestParam String id) {
        return Response.success(sysRecordLogService.getById(id));
    }

    @GetMapping("/get-by-businessId")
    @Description("根据业务id获取记录")
    public Response getByBusinessId(@RequestParam String businessId) {
        return Response.success(sysRecordLogService.getByBusinessId(businessId));
    }

    @GetMapping("/get-by-classify")
    @Description("根据分类获取记录")
    public Response getByClassify(@RequestParam String classify) {
        return Response.success(sysRecordLogService.getByClassify(classify));
    }

    @GetMapping("/get-by-code")
    @Description("根据code虎丘记录")
    public Response getByCode(@RequestParam String code) {
        return Response.success(sysRecordLogService.getByCode(code));
    }

    @GetMapping("/delete-all")
    @Description("删除所有的记录")
    public Response deleteAll() {
        return Response.success(sysRecordLogService.deleteAll());
    }

    @GetMapping("/delete-by-ids")
    @Description("根据id删除记录")
    public Response deleteByIds(@RequestParam List<String> ids) {
        return Response.success(sysRecordLogService.deleteByIds(ids));
    }

    @GetMapping("/delete-by-businessIds")
    @Description("根据业务id删除记录")
    public Response deleteByBusinessIds(@RequestParam List<String> businessIds) {
        return Response.success(sysRecordLogService.deleteByBusinessIds(businessIds));
    }

    @GetMapping("/delete-by-classifies")
    @Description("根据classify删除记录")
    public Response deleteByClassifies(@RequestParam List<String> classifies) {
        return Response.success(sysRecordLogService.deleteByClassifies(classifies));
    }

}
